on hINIFileCheck INIFileName, sectionName, varName
set txt to hGetTextOfFile(INIFileName)
if char 1 of sectionName <> "[" then
put "[" before sectionName
end if
if char length(sectionName) of sectionName <> "]" then
put "]" after sectionName
end if
set n to the number of lines in txt
set LINEBREAK to numToChar(10)
set oldDelim to the itemDelimiter
set retVal to EMPTY
set the itemDelimiter to "="
repeat with i = 1 to n
set txtLine to line i of txt
if char 1 of txtLine = LINEBREAK then
delete char 1 of txtLine
end if
if txtLine = sectionName then
repeat with j = i + 1 to n
set txtLine to line j of txt
if char 1 of txtLine = LINEBREAK then
delete char 1 of txtLine
end if
if item 1 of txtLine = varName then
set retVal to item 2 to 1000 of txtLine
exit repeat
end if
end repeat
end if
if retVal <> 0 then
exit repeat
end if
end repeat
set the itemDelimiter to oldDelim
return retVal
end
on hBotherCheckingForWinVersions
set retVal to 0
if hINIFileCheck(the pathName & "OMNI_SP.INI", "winVersionCheck", "stopOnWin95") = 1 then
set retVal to 1
end if
return retVal
end
on hWinVoiceAvailable
global gProjectorPath
set fileList to "dragdev.dll,dragon.dll,environ.dll,fileio.dll,wintalkd.dll"
set oldDelim to the itemDelimiter
set the itemDelimiter to ","
set n to the number of items in fileList
set avail to 1
repeat with i = 1 to n
set thefile to item i of fileList
if not hFileIsHere(gProjectorPath & thefile) then
put thefile && "is missing!!!!!!!!!!!!!!!!!!!"
set avail to 0
next repeat
end if
put thefile && "is here."
end repeat
set the itemDelimiter to oldDelim
return avail
end
on hWINenvirVerify
if not hFileIsHere(the moviePath & "ENVIRON.DLL") then
cursor([gTrekCursor, gTrekCursor + 1])
set gWinVoiceEnabled to 0
return 0
else
openXLib(the moviePath & "ENVIRON.DLL")
set Widget to Environment(mnew)
set winver to Widget(mWinVersion)
set dosver to Widget(mDosVersion)
set Lv to float(winver)
if Lv < 3.20000000000000018 then
set Lok to 1
else
set Lok to 0
end if
Widget(mdispose)
set Widget to 0
closeXLib(the moviePath & "ENVIRON.DLL")
return Lok
end if
end
on hWinVoiceGetUsername
set proposedUsername to hINIFileCheck("OMNI_SP.INI", "filenames", "dragonUserFile")
set newUsername to "omni.usr"
if proposedUsername <> EMPTY then
if hFileIsHere(the moviePath & proposedUsername) then
set newUsername to proposedUsername
end if
end if
return newUsername
end
on hWinVoiceGetVocname
set proposedVocname to hINIFileCheck("OMNI_SP.INI", "filenames", "dragonVocFile")
set newVocname to "omni.voc"
if proposedVocname <> EMPTY then
if hFileIsHere(the moviePath & proposedVocname) then
set newVocname to proposedVocname
end if
end if
return newVocname
end
on hWinVoiceDebugCheck
set shouldDebug to 0
set shouldDebug to hINIFileCheck("OMNI_SP.INI", "misc", "debugging")
if shouldDebug = "1" then
gWinVoiceXobj(mStartDebug)
end if
end
on hWinVoiceOpen
global gComputerTypeK, gProjectorPath
cursor(4)
set gWinVoiceEnabled to 0
set gWINListenStatus to 0
set gVoiceCmd to EMPTY
set gVoiceConfidence to EMPTY
set gWinVoiceLastCmd to EMPTY
set gSpeechCapable to 0
set gWinVoiceStartedWaiting to 0
set gMaxLinks to 20
set gVoicemode to EMPTY
if gComputerTypeK <> #WIN then
return
end if
if gCurrentlyPlayingMovie contains "\" then
tell window gCurrentlyPlayingMovie
do("closeWindow")
end tell
end if
if hBotherCheckingForWinVersions() then
if not hWINenvirVerify() then
alert("Sorry, the voice recognition software is not compatible with this version of Microsoft Windows. Program will proceed without attempting speech recognition.")
cursor([gTrekCursor, gTrekCursor + 1])
set gWinVoiceEnabled to 0
return 0
end if
end if
puppetSound(0)
set gWinVoiceEnabled to 1
set gSpeechCapable to 1
put "gProjectorPath=" & gProjectorPath
set Lfilepath to the moviePath & "wintalkd.dll"
if not hFileIsHere(Lfilepath) then
cursor([gTrekCursor, gTrekCursor + 1])
set gWinVoiceEnabled to 0
end if
openXLib(Lfilepath)
put ">hWinWoiceOpen trying to initialize the Xobj at" && Lfilepath
set gWinVoiceXobj to Widget(mnew)
if objectp(gWinVoiceXobj) = 0 then
put ">hWinVoiceOpen COULD NOT OPEN " & Lfilepath
set gWinVoiceEnabled to 0
cursor([gTrekCursor, gTrekCursor + 1])
return
end if
hWinVoiceDebugCheck()
set username to hWinVoiceGetUsername()
set vocname to hWinVoiceGetVocname()
set success to gWinVoiceXobj(mOpenDriver, vocname, username)
if success = 0 then
beep()
set gWinVoiceEnabled to 0
else
set gWinVoiceSuspended to 0
set gWinVoiceEnabled to 1
set gSpeechCapable to 1
end if
set gWINListenStatus to 1
set gWINListenStatus to 0
set gCurrentlyPlayingMovie to EMPTY
hWinVoiceMicOn(0)
if hWinVoiceMicState() then
set gWinVoiceStartedWaiting to the ticks
hReportStatus("Please wait 5 seconds before speaking...")
end if
cursor([gTrekCursor, gTrekCursor + 1])
end
on hWinVoiceInitInterface
set gCurrentlyPlayingMovie to EMPTY
if hWinVoiceAvailable() then
hShowSpeechStatus(#INACTIVE)
set gSpeechCapable to 1
end if
end
on hWINvoistats
put "objectP(gWinVoiceXobj):" & objectp(gWinVoiceXobj)
put "gSpeechCapable:" & gSpeechCapable
put "gWinVoiceEnabled:" & gWinVoiceEnabled
put "gWINListenStatus:" & gWINListenStatus
end
on hWinVoiceClose
if objectp(gWinVoiceXobj) then
put ">hWinVoiceClose called..."
if gVoiceDisabled <> "1" then
put gWinVoiceXobj(mCloseDriver)
put gWinVoiceXobj(mdispose)
set gWinVoiceXobj to 0
closeXLib(the moviePath & "wintalkd.dll")
end if
end if
set gWinVoiceEnabled to 0
end
on hWinVoiceMicOn pWithAnnc
global gCurrentlyPlayingMovie
updateStage()
if gCurrentlyPlayingMovie <> EMPTY then
else
if objectp(gWinVoiceXobj) then
if (gModeState = #TOPICS) or gVidIsPlaying then
return
end if
if gSpeechWasChosenF = 0 then
return
end if
put "gWinVoiceEnabled=" & gWinVoiceEnabled
if gWinVoiceEnabled = 1 then
if gWINListenStatus = 0 then
puppetSound(0)
updateStage()
repeat while soundBusy(1)
nothing()
end repeat
repeat while soundBusy(2)
nothing()
end repeat
gWinVoiceXobj(mSetMicState, 1)
put "after setmicstate, mic = " & gWinVoiceXobj(mGetMicState)
if pWithAnnc = 1 then
put "ANNOUNCING FROM HWINVOICEON"
hAnnounce("Voice Rec Activated")
end if
set gWINListenStatus to 1
hShowSpeechStatus(#READY)
hReportStatus("Speech microphone ready...")
end if
end if
end if
end if
end
on hWinVoiceMicOff
if objectp(gWinVoiceXobj) then
if gWinVoiceEnabled = 1 then
if gWINListenStatus = 1 then
gWinVoiceXobj(mSetMicState, 0)
set gWinVoiceSuspended to 0
set gWINListenStatus to 0
hShowSpeechStatus(#STANDBY)
hReportStatus("Speech microphone turned off...")
end if
end if
end if
end
on hWinVoiceSuspend
if objectp(gWinVoiceXobj) then
if gWinVoiceEnabled = 1 then
if gWINListenStatus = 1 then
set gWinVoiceSuspended to hWinVoiceMicState()
gWinVoiceXobj(mSetMicState, 0)
set gWINListenStatus to 0
end if
end if
end if
end
on hWinVoiceResume
if gWinVoiceSuspended <> 1 then
return
end if
if objectp(gWinVoiceXobj) then
if (gModeState = #TOPICS) or gVidIsPlaying then
return
end if
if gSpeechWasChosenF = 0 then
return
end if
if gWinVoiceEnabled = 1 then
if gWINListenStatus = 0 then
repeat while soundBusy(1)
nothing()
end repeat
repeat while soundBusy(2)
nothing()
end repeat
puppetSound(0)
updateStage()
gWinVoiceXobj(mSetMicState, 1)
put "after setmicstate, mic = " & gWinVoiceXobj(mGetMicState)
set gWINListenStatus to 1
end if
end if
end if
end
on hWinVoiceMicState
if gVoiceDisabled = "1" then
return 0
end if
if objectp(gWinVoiceXobj) then
set micIsOn to gWinVoiceXobj(mGetMicState)
return micIsOn
else
return 0
end if
end
on hWinVoiceIdle dontUpdateInterface
global gdescfield, gSpeechCapable, gComputerTypeK
if gComputerTypeK <> #WIN then
return
end if
if gSpeechCapable = 0 then
return
end if
if gVoiceDisabled = "1" then
set gWINListenStatus to 0
set gWinVoiceEnabled to 0
if dontUpdateInterface <> 1 then
hShowSpeechStatus(#null)
end if
return
end if
if gWinVoiceStartedWaiting > 0 then
if (the ticks - gWinVoiceStartedWaiting) > 300 then
set gWinVoiceStartedWaiting to 0
hReportStatus("Speech Ready...")
end if
end if
if gWinVoiceEnabled <> 1 then
if dontUpdateInterface <> 1 then
hShowSpeechStatus(#INACTIVE)
end if
return
end if
set micIsOn to gWinVoiceXobj(mGetMicState)
if gVoiceCmd = EMPTY then
if micIsOn = 1 then
if dontUpdateInterface <> 1 then
hShowSpeechStatus(#READY)
end if
else
if dontUpdateInterface <> 1 then
hShowSpeechStatus(#STANDBY)
end if
end if
else
if dontUpdateInterface <> 1 then
hReportStatus("Interpreting >" & gVoiceCmd & "<")
end if
set gVoiceConfidence to integer(gVoiceConfidence)
if gVoiceConfidence < 10 then
hFlushWINvoiGlobals()
hReportStatus(" Could not recognize command, please try again. Speak clearly and loudly.")